<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Provides a driver-based interface for finding, creating, and deleting cached
 * resources. Caches are identified by a unique string. Tagging of caches is
 * also supported, and caches can be found and deleted by id or tag.
 *
 * $Id: Cache.php 4321 2009-05-04 01:39:44Z kiall $
 *
 * @package    Cache
 * @author     Kohana Team
 * @copyright  (c) 2007-2008 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
class KfppAdmin_Core {

  private $FastText = NULL;
  private $ModelDefault = NULL;

  function SetModule($name_block,$ModelInvoke){
    $this->block[$name_block][] = $ModelInvoke;
  }

  function SetFastText($array){
    $this->FastText = $array;
  }
  
  function SetModelDefault($module){
    $this->ModelDefault = $module;
  }
  
  function __toString(){
    $modval = "";
    $uri = New Uri();
    $seg = $uri->segment('mod');
    if($this->ModelDefault <> NULL and $seg == ''){
      $seg = $this->ModelDefault ;
    }
    if($seg <> ''){
      $lload = "fpp_{$seg}_Model";
      $libload = new $lload;
      $libload->set_property('edit',1);
      $libload->set_property('delete',1);
      $libload->set_property('add',1);
      $modval = $libload->autoblock();
    }
    $str = '';
    if(@$_GET['AJAX_NO_LOAD'] == 'TRUE'){
      return $modval;
    }
    foreach($this->block as $HeadModule => $Module){

      $str .= "<div class='HeadModule HM_{$HeadModule}'>{$HeadModule}</div>";
      foreach($Module as $valuemod){
//         echo Kohana::debug($this->FastText[$valuemod]);
        $modulename = Router::$controller.'/'.Router::$method.'/mod/'.$valuemod.'/action';
        $textvaluemod = (@$this->FastText[$valuemod] == "") ? $valuemod : $this->FastText[$valuemod];
        $modulename = html::anchor($modulename,$textvaluemod,array('class'=>'kfppadmin_list'));
        $str .= "<div class='ModuleName MN_{$valuemod}'>
                    {$modulename}
                </div>";
      }
    }
    $str .= "<div class='FooterModule'>&nbsp;&nbsp;</div>";
    return "<table width='100%' ><tr><td width='20%' id='tdizq'  valign='top' >
    <div class='contentmenu'>
    {$str}
    </div>
    </td><td id='tdder' valign='top'>{$modval}</td></tr></table>";
  }
  
}